﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<brjostagjof.Models.Question>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Spurningar og svör
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <% if (Page.User.IsInRole("Administrators") || Page.User.IsInRole("Specialists") || Page.User.IsInRole("PublicUser"))
       { %>
    <a href="/Home/AddQuestion/" class="linksWhite">Ný spurning</a>
     <%} %>
    <% if (Page.User.IsInRole("Administrators"))
       { %>

      <a href="/Home/AddQuestionsCategory/" class="linksWhite">Nýr sp. flokkur</a>
    <% } %>
    <a href="/Home/Index/" class="linksWhite">Til baka á forsíðu</a>
    <h2>Spurningaflokkar svaraðra spurninga:</h2>

        <ul>
        <% var categories = brjostagjof.Controllers.HomeController.GetQuestionCategories();
        foreach (var category in categories)
        { %>
            <li>
            <a href="/Home/GetQuestionByCategoryID/<%: category.ID %>"><%: category.name%></a>
            </li>
        <% } %>
        </ul>

    <h2>Nýjustu spurningar og svör:</h2>

        <% var latestQuestions = brjostagjof.Controllers.HomeController.Get10Questions();
        foreach (var item in latestQuestions)
        { %>
        <div class="entry">
        <div class="entry-bgtop">
        <div class="entry-bgbtm">
            <h2 class="title"><a href="<%: item.ArticleBase.link %><%: item.articleBaseID %>"><%: item.ArticleBase.InformationBase.headline%></a></h2>
            <p class="meta">Höfundur: <a href="../../MySite/ViewUserByID/<%:item.ArticleBase.User.ID  %>"><%: item.ArticleBase.User.name%></a>,  <%: item.ArticleBase.InformationBase.date%> 
	            &nbsp;&bull;&nbsp; 
                <a href="/Home/GetQuestionByCategoryID/<%: item.ArticleBase.ArticleCategory.ID %>" class="permalink"> <%: item.ArticleBase.ArticleCategory.name %></a>
                &nbsp;&bull;&nbsp;
                <a href="<%: item.ArticleBase.link %><%: item.ArticleBase.informationBaseID %>" class="permalink">Öll spurning með svari</a></p>
        </div>
        </div>
        </div>
        <%  } %>

            <% int page = 1; %>
            <% for (int i = page-4; i < page+5; i++)
            {%>
                <% if(i == 0)
                   { %>
                   <a href="/Home/SogS/">1</a>
                   <% }%>
                 <% if ((i > 0) && (i <= ((brjostagjof.Controllers.HomeController.GetAllQuestionsCount())/10)))
                { %>
                    <a href="/Home/Get10QuestionsByPageID/<%: i %>"><%: i + 1 %></a>
               <% }%>
           <% } %>
           <a href="/Home/Get10QuestionsByPageID/1" class="linksWhite">Eldri spurningar</a>

</asp:Content>
